package mock.servicesdirectory.organisations.dao.daoimpl;

import java.util.List;

import mock.servicesdirectory.common.entities.Directorate;
import mock.servicesdirectory.common.entities.SupportingMaterial;
import mock.servicesdirectory.organisations.business.businessinterface.SupportingMaterialBO;
import mock.servicesdirectory.organisations.dao.daointerface.SupportingMaterialDAO;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class SupportingMaterialDAOImpl extends HibernateDaoSupport implements SupportingMaterialDAO{

	// Method to get All suporting material
	@Override
	public List<SupportingMaterial> getSupportingMaterial() {
		// TODO Auto-generated method stub
		// Query in database
		
		return getHibernateTemplate().find("from SupportingMaterial");
	}

	// Method to get the supporting material of an organisation
	@Override
	public List<SupportingMaterial> getSupportingMaterial(int orgid) {
		// TODO Auto-generated method stub
		// Query in database
		
		String sql;
		List<SupportingMaterial> sm;
		sql = "from SupportingMaterial where OrgId = :orgid";
		Session session = this.getSession();
		Query query = session.createQuery(sql);
		query.setParameter("orgid", orgid);			
		sm = query.list();
		return sm ;
	}

	// Check url is exist in database 
	@Override
	public boolean checkExistUrl(String url, int orgid) {
		// TODO Auto-generated method stub
		
		return false;
	}

}
